Model Not Valid Even With No [Required] Attribute

Posted by griegs on Stack Overflow See other posts from Stack Overflow or by griegs
Published on 2010-04-16T00:06:30Z Indexed on 2010/04/16 0:13 UTC
Read the original article Hit count: 586

Filed under:
|

I have a model which is validating as False even though I have no validation rules attached to it what so ever.

So this is my model;

public class QuickQuote
{
    public Enumerations.AUSTRALIA_STATES  state { get; set; }

    public Enumerations.FAMILY_TYPE familyType { get; set; }

    public Enumerations.CoverLevel hospitalCover { get; set; }

    public Enumerations.CoverLevel extrasCover { get; set; }

    public Enumerations.YesNo pregnancy { get; set; }
}

And in my controller I have;

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(IndexFormViewModel fvm)
    {
        if (!ModelState.IsValid)
            return View(fvm);

The problem is that unless I put a value into each field it's validating as false even though it shouldn't care.

Can anyone see what the problem is here?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about validation